function getCookie(key) {
    //获取cookie  document.cookie
    var cookie = document.cookie;
    var arr = cookie.split('; ');
    //遍历arr
    for (var i = 0; i < arr.length; i++) {
        var item = arr[i].split('=');
        if (item[0] == key) {
            return item[1];  //item[0代表键]   item[1]代表值
        }
    }
    return '';
}

//设置cookie
function setCookie(key,value,day){
   var m=new Date();
   m.setDate(m.getDate()+day);
   document.cookie=key+"="+value+";expires="+m;
}

//删除cookie
function delCookie(key){
    setCookie(key," ",-1);
}